﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace Apex.Commons.ConfigurationCenter
{
    internal static class JsonElementExtensions
    {
        public static string GetValueForConfig(this JsonElement e)
        {
            if (e.ValueKind == JsonValueKind.String)
            {
                return e.GetString();
            }

            if (e.ValueKind == JsonValueKind.Null || e.ValueKind == JsonValueKind.Undefined)
            {
                return null;
            }

            return e.GetRawText();
        }
    }
}
